package com.akk.action;


import com.akk.business.AvsCjPayBusiness;
import com.akk.module.cjpay.model.CjpayNotifyRequest;
import com.akk.utils.RestResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 畅捷
 */
@RestController
@RequestMapping("/thmlfApi/avs/cjpay")
public class AvsCjPayAction {

    @Autowired
    private AvsCjPayBusiness cjPayBusiness;

    @PostMapping("/payment")
    @ApiOperation(value = "直接支付",notes = "直接支付",httpMethod = "POST",response = String.class)
    public RestResponse payment(String payerId,String orderNum,String accessBind){
        return cjPayBusiness.payment(payerId, orderNum, accessBind);
    }

    @PostMapping("/bindCardQuery")
    @ApiOperation(value = "绑卡查询",notes = "绑卡查询",httpMethod = "POST",response = String.class)
    public RestResponse bindCardQuery(String payerId,String orderNum,String accessBind){
        return cjPayBusiness.bindCardQuery(payerId, orderNum, accessBind);
    }

    @PostMapping("/bindCard")
    @ApiOperation(value = "绑卡",notes = "绑卡",httpMethod = "POST",response = String.class)
    public RestResponse bindCard(String payerId,String orderNum,String accessBind){
        return cjPayBusiness.bindCard(payerId, orderNum, accessBind);
    }

    @GetMapping("/returnUrl")
    @ApiOperation(value = "返回地址",notes = "返回地址",httpMethod = "POST",response = String.class)
    public String returnUrl(String status, String trxId, String merUserId, String accessBind, String amount,HttpServletResponse response){
        return cjPayBusiness.returnUrl(status,merUserId, trxId, accessBind,amount,response);
    }

    @PostMapping("/paymentNotify")
    @ApiOperation(value = "支付通知",notes = "支付通知", httpMethod = "POST", response = RestResponse.class)
    public String paymentNotify(CjpayNotifyRequest request) {
        return cjPayBusiness.paymentNotify(request);
    }


}
